package com.fyzk.activity.lottery.gaopin;

import android.content.Intent;
import android.graphics.Rect;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AbsListView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.fyzk.activity.app.AppToast;
import com.fyzk.activity.down_numhistory.NumHistoryPrizeView;
import com.fyzk.activity.lottery.shuzicai.BallInfo;
import com.fyzk.activity.lottery.shuzicai.LotteryBaseActivity;
import com.fyzk.activity.lottery.shuzicai.SelectBallView;
import com.fyzk.activity.lottery.shuzicai.TouZhuHelper;
import com.fyzk.activity.lottery.shuzicai.klpk.KLPKPopupItemBean;
import com.fyzk.activity.lottery.shuzicai.klpk.KLPKPopupwindow;
import com.fyzk.activity.myview.BallPopFrameLayout;
import com.fyzk.activity.myview.BallScrollView;
import com.fyzk.activity.myview.DrawBallFrameLayout;
import com.fyzk.activity.myview.WeiZhi;
import com.fyzk.activity.trend.Gp11x5TrendActivity;
import com.fyzk.bean.PrizeHistoryItem;
import com.fyzk.betzhushu.ZhuShuFactory;
import com.fyzk.data.AppLotteryInfos;
import com.fyzk.interfaces.onTopTitleClickListener;
import com.fyzk.random.RandomFactory;
import com.fyzk.utils.HelpUrlConstants;
import com.fyzk.utils.IntentParamUtils;
import com.fyzk.utils.LotteryIDUtils;
import com.fyzk.view.BottomView;
import com.fyzk.view.BottomView.onBottomClickListener;
import com.fyzk.view.TopTitleView;
import com.fyzk.view.ViewCallBack;
import com.tyjc.lottery.R;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;

import java.util.ArrayList;
import java.util.List;

@ContentView(R.layout.ac_gp_11xuan5)
public class Gp11x5BaseActivity extends LotteryBaseActivity implements
        onTopTitleClickListener, onBottomClickListener, KLPKPopupwindow.KLPKPopuponItemListener{

    //顶部
    protected TopTitleView topView;
    protected int[] popup_itemsId = {R.string.gp_11xuan5_popu_ren2,
            R.string.gp_11xuan5_popu_ren3, R.string.gp_11xuan5_popu_ren4,
            R.string.gp_11xuan5_popu_ren5, R.string.gp_11xuan5_popu_ren6,
            R.string.gp_11xuan5_popu_ren7, R.string.gp_11xuan5_popu_ren8,
            R.string.gp_11xuan5_popu_qian1, R.string.gp_11xuan5_popu_qian2_zhi,
            R.string.gp_11xuan5_popu_qian2_zu,
            R.string.gp_11xuan5_popu_qian3_zhi,
            R.string.gp_11xuan5_popu_qian3_zu,
            R.string.gp_11xuan5_popu_ren2_dan,
            R.string.gp_11xuan5_popu_ren3_dan,
            R.string.gp_11xuan5_popu_ren4_dan,
            R.string.gp_11xuan5_popu_ren5_dan,
            R.string.gp_11xuan5_popu_ren6_dan,
            R.string.gp_11xuan5_popu_ren7_dan,
            R.string.gp_11xuan5_popu_qian2_zu_dan,
            R.string.gp_11xuan5_popu_qian3_zu_dan};
    private String[] popup_itemsStr2 = {"奖金","奖金","奖金","奖金","奖金","奖金","奖金"
            ,"奖金","奖金","奖金","奖金","奖金","","","","","","","",""};
    private String[] popup_itemsStr3 = {"6米","19米","78米","540米","90米","26米",
            "9米","13米","130米","65米","1170米","195米","","","","","","","",""};
    //    private String[] popup_items = new String[popup_itemsId.length];
//    private HM_Popupwindow top_popup;
    protected List<KLPKPopupItemBean> popup_items = new ArrayList<>();
    protected KLPKPopupwindow top_popup;

    //中间
    private LinearLayout ll_history;
//    private DrawBallFrameLayout ll_up_down;
//    private ChartBaseView chartBaseView;

    protected LinearLayout ball_ll_dan;
    protected LinearLayout ball_ll_two;
    protected LinearLayout ball_ll_three;

    protected TextView balltitle_first;
    protected TextView balltitle_two;
    protected TextView balltitle_three;

    protected TextView ball_tiShi_dan;
    protected TextView ball_tiShi_first;
    protected TextView ball_tiShi_two;
    protected TextView ball_tiShi_three;

    protected TextView prize_tishi_tv;

    protected SelectBallView ballView_dan;
    protected SelectBallView ballView_first;
    protected SelectBallView ballView_two;
    protected SelectBallView ballView_three;

    protected int ball_count = 11;
    protected List<BallInfo> balls_danLine = new ArrayList<BallInfo>();
    protected List<BallInfo> balls_firstLine = new ArrayList<BallInfo>();
    protected List<BallInfo> balls_twoLine = new ArrayList<BallInfo>();
    protected List<BallInfo> balls_threeLine = new ArrayList<BallInfo>();

    public static final int DAN_REN2 = 1;
    public static final int DAN_REN3 = 2;
    public static final int DAN_REN4 = 3;
    public static final int DAN_REN5 = 4;
    public static final int DAN_REN6 = 5;
    public static final int DAN_REN7 = 6;
    public static final int DAN_QIAN2_ZHI = 1;
    public static final int DAN_QIAN3_ZHI = 2;

    protected DrawBallFrameLayout ball_linear;
    protected BallScrollView ball_scroll;
    protected BallPopFrameLayout moveQiu;

    protected int wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENER_DAN_ID_INT;

    //底部
    protected BottomView bottomView;
    @ViewInject(R.id.shake_random_ll)
    protected LinearLayout shake_random_ll;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        shake_random_ll.setOnClickListener(this);
        initView();
        ViewCallBack.getInstance().AttachCountDownObj(this);

        top_popup.setCheckItem(popupId);
        topView.setCenterText(AppLotteryInfos.getLotteryName(getLotteryId()) + " - "
                + popup_items.get(popupId).str1);
//		clear();
        popupClickItem(popupId);
        ballClick();
    }

    @Override
    public TopTitleView getTopView() {
        return topView;
    }

    private void initView() {
        //顶部
        for (int i = 0; i < popup_itemsId.length; i++) {

            KLPKPopupItemBean itemBean = new KLPKPopupItemBean();
            itemBean.str1 = getString(popup_itemsId[i]);
            itemBean.str2 = popup_itemsStr2[i];
            itemBean.str3 = popup_itemsStr3[i];
            popup_items.add(itemBean);
        }

        top_popup = new KLPKPopupwindow(this, AbsListView.LayoutParams.MATCH_PARENT, AbsListView
                .LayoutParams.WRAP_CONTENT,
                popup_items, 12);
        top_popup.setHm_PopupOnItemListener(this);

        topView = (TopTitleView) findViewById(R.id.gp_11xuan5_topTitle);
        topView.setCenterText(AppLotteryInfos.getLotteryName(getLotteryId()) + " - "
                + popup_items.get(popupId).str1);
        topView.setRightVisible(View.VISIBLE);
        topView.setRight2Visible(View.VISIBLE);
        topView.getRightImg2().setImageDrawable(getResources().getDrawable(R.drawable.icon_refresh));
        topView.setRightImg(R.drawable.downmenu_icon);
        topView.setJianTouVisible(View.VISIBLE);
        topView.setOnTitleClickListener(this);
        View view_pop = LayoutInflater.from(this).inflate(
                R.layout.hm_popupwindow, null);

        //中间
        ll_history = (LinearLayout) findViewById(R.id.gp_11xuan5_ball_history);
//        ll_up_down = (DrawBallFrameLayout) findViewById(R.id.gp_11xuan5_drawball_framelayout);

        ball_ll_dan = (LinearLayout) findViewById(R.id.gp_11xuan5_ll_dan);
        ball_ll_two = (LinearLayout) findViewById(R.id.gp_11xuan5_ll_two);
        ball_ll_three = (LinearLayout) findViewById(R.id.gp_11xuan5_ll_three);

        balltitle_first = (TextView) findViewById(R.id.gp_11xuan5_balltitle_first);
        balltitle_two = (TextView) findViewById(R.id.gp_11xuan5_balltitle_two);
        balltitle_three = (TextView) findViewById(R.id.gp_11xuan5_balltitle_three);

        ball_tiShi_dan = (TextView) findViewById(R.id.gp_11xuan5_tishi_dan);
        ball_tiShi_first = (TextView) findViewById(R.id.gp_11xuan5_tishi_first);
        ball_tiShi_two = (TextView) findViewById(R.id.gp_11xuan5_tishi_two);
        ball_tiShi_three = (TextView) findViewById(R.id.gp_11xuan5_tishi_three);
        prize_tishi_tv = (TextView) findViewById(R.id.prize_tishi_tv);

        ballView_dan = (SelectBallView) findViewById(R.id.gp_11xuan5_ballview_dan);
        ballView_first = (SelectBallView) findViewById(R.id.gp_11xuan5_ballview_first);
        ballView_two = (SelectBallView) findViewById(R.id.gp_11xuan5_ballview_tow);
        ballView_three = (SelectBallView) findViewById(R.id.gp_11xuan5_ballview_three);

        initArrayInfos();

        // 设置关联选球SelectView
        ballView_dan.setGuanLian_view(ballView_first);
        List<SelectBallView> guoLian_first = new ArrayList<SelectBallView>();
        guoLian_first.add(ballView_dan);
        guoLian_first.add(ballView_two);
        guoLian_first.add(ballView_three);
        List<SelectBallView> guoLian_two = new ArrayList<SelectBallView>();
        guoLian_two.add(ballView_first);
        guoLian_two.add(ballView_three);
        List<SelectBallView> guoLian_three = new ArrayList<SelectBallView>();
        guoLian_three.add(ballView_first);
        guoLian_three.add(ballView_two);
        ballView_first.setGuanLian_view(guoLian_first);
        ballView_two.setGuanLian_view(guoLian_two);
        ballView_three.setGuanLian_view(guoLian_three);

        ball_linear = (DrawBallFrameLayout) findViewById(R.id.gp_11xuan5_drawball_framelayout);
        ball_scroll = (BallScrollView) findViewById(R.id.gp_11xuan5_ballscroll);
        moveQiu = (BallPopFrameLayout) findViewById(R.id.gp_11xuan5_fl_moveqiu);
        ball_linear.setScr(ball_scroll);
        ball_linear.setFl_moveqiu(moveQiu);
        ball_linear.setUpOrDownListener(this);

        TouZhuHelper.getInstance().setBallClickListener(this);
        TouZhuHelper.getInstance().setBallItemClickLitener(this);

        // 底部
        bottomView = (BottomView) findViewById(R.id.gp_11xuan5_bottom);
        bottomView.setRightText("确定");
        bottomView.setLeftText("清除");
        bottomView.setonBottomClickListener(this);
        bottomView.setMoRenText1(0 + "注 ");
        bottomView.setMoRenText2("共" + 0 + "米");

    }

    @Override
    protected void initArrayInfos() {
        if (arr_infos.size() > 0) {
            balls_danLine = arr_infos.get(0);
            balls_firstLine = arr_infos.get(1);
            balls_twoLine = arr_infos.get(2);
            balls_threeLine = arr_infos.get(3);
        } else {
            initBallList(balls_danLine, ball_count, 1, true);
            initBallList(balls_firstLine, ball_count, 1, true);
            initBallList(balls_twoLine, ball_count, 1, true);
            initBallList(balls_threeLine, ball_count, 1, true);
            arr_infos.add(balls_danLine);
            arr_infos.add(balls_firstLine);
            arr_infos.add(balls_twoLine);
            arr_infos.add(balls_threeLine);
        }

        ballView_dan.setBallInfoList(balls_danLine);
        ballView_first.setBallInfoList(balls_firstLine);
        ballView_two.setBallInfoList(balls_twoLine);
        ballView_three.setBallInfoList(balls_threeLine);
    }

    // ========== popuwindow =================
    @Override
    public void onItem(int position) {

//        ball_linear.requestingData();

        clear();
        popupClickItem(position);
    }

    @Override
    public void popupShow() {
        topView.setJianTouRotate_shun();

    }

    @Override
    public void popupDismiss() {
        topView.setJianTouRotate_ni();

    }

    // ========== popuwindow =================

    // ========== topTitle =================
    @Override
    public void onLeftClick() {
        onBackPressed();
    }

    @Override
    public void onCenterClick() {
        top_popup.showPopupWindow(topView);
    }

    @Override
    public void onRightClick() {
        toHelp();
    }

    // ========== topTitle =================

    // ========== bottom =================
    @Override
    public void onBottomLeftClick() {
        clear();
    }

    @Override
    public void onBottomRightClick() {
        if (!touZhu()) {
            AppToast.getToast().show("请先选择一注再投注");
        }
    }

    // ========== bottom =================

    @Override
    public boolean touZhu() {
        long zhuShu = getZhushu();
        if (zhuShu > 0) {
            int lotteryId = wanFaId;
            switch (wanFaId) {
                case LotteryIDUtils.SD11XUAN5_LOTTERY_RENER_DAN_ID_INT:
                    if (zhuShu > 1) {
                        lotteryId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENER_FU_ID_INT;
                    }
                    break;
                case LotteryIDUtils.SD11XUAN5_LOTTERY_RENSAN_DAN_ID_INT:
                    if (zhuShu > 1) {
                        lotteryId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENSAN_FU_ID_INT;
                    }
                    break;
                case LotteryIDUtils.SD11XUAN5_LOTTERY_RENSI_DAN_ID_INT:
                    if (zhuShu > 1) {
                        lotteryId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENSI_FU_ID_INT;
                    }
                    break;
                case LotteryIDUtils.SD11XUAN5_LOTTERY_RENWU_DAN_ID_INT:
                    if (zhuShu > 1) {
                        lotteryId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENWU_FU_ID_INT;
                    }
                    break;
                case LotteryIDUtils.SD11XUAN5_LOTTERY_RENLIU_DAN_ID_INT:
                    if (zhuShu > 1) {
                        lotteryId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENLIU_FU_ID_INT;
                    }
                    break;
                case LotteryIDUtils.SD11XUAN5_LOTTERY_RENQI_DAN_ID_INT:
                    if (zhuShu > 1) {
                        lotteryId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENQI_FU_ID_INT;
                    }
                    break;
                case LotteryIDUtils.SD11XUAN5_LOTTERY_RENBA_DAN_ID_INT:
                    if (zhuShu > 1) {
                        lotteryId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENBA_FU_ID_INT;
                    }
                    break;
                case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANYI_DAN_ID_INT:
                    if (zhuShu > 1) {
                        lotteryId = LotteryIDUtils.SD11XUAN5_LOTTERY_QIANYI_FU_ID_INT;
                    }
                    break;
                case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANER_DAN_ID_INT:
                    if (zhuShu > 1) {
                        lotteryId = LotteryIDUtils.SD11XUAN5_LOTTERY_QIANER_FU_ID_INT;
                    }
                    break;
                case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANSAN_DAN_ID_INT:
                    if (zhuShu > 1) {
                        lotteryId = LotteryIDUtils.SD11XUAN5_LOTTERY_QIANSAN_FU_ID_INT;
                    }
                    break;
                case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANER_ZU_DAN_ID_INT:
                    if (zhuShu > 1) {
                        lotteryId = LotteryIDUtils.SD11XUAN5_LOTTERY_QIANER_ZU_FU_ID_INT;
                    }
                    break;
                case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANSAN_ZU_DAN_ID_INT:
                    if (zhuShu > 1) {
                        lotteryId = LotteryIDUtils.SD11XUAN5_LOTTERY_QIANSAN_ZU_FU_ID_INT;
                    }
                    break;
                case LotteryIDUtils.SD11XUAN5_LOTTERY_RENER_TOWED_ID_INT:
                case LotteryIDUtils.SD11XUAN5_LOTTERY_RENSAN_TOWED_ID_INT:
                case LotteryIDUtils.SD11XUAN5_LOTTERY_RENSI_TOWED_ID_INT:
                case LotteryIDUtils.SD11XUAN5_LOTTERY_RENWU_TOWED_ID_INT:
                case LotteryIDUtils.SD11XUAN5_LOTTERY_RENLIU_TOWED_ID_INT:
                case LotteryIDUtils.SD11XUAN5_LOTTERY_RENQI_TOWED_ID_INT:
                case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANER_ZU_TOWED_ID_INT:
                case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANSAN_ZU_TOWED_ID_INT:
                    if (zhuShu < 2) {
                        AppToast.getToast().show("胆拖至少选择2注");
                        return true;
                    } else {
                        break;
                    }

                default:
                    break;
            }

            touZhu1(lotteryId, zhuShu);
            return true;
        } else {
            return false;
        }

    }

    @Override
    public void clear() {

        bottomView.setMoRenText1(0 + "注 ");
        bottomView.setMoRenText2("共" + 0 + "米");

        initBallList(balls_danLine, ball_count, 1, true);
        initBallList(balls_firstLine, ball_count, 1, true);
        initBallList(balls_twoLine, ball_count, 1, true);
        initBallList(balls_threeLine, ball_count, 1, true);

        ballView_dan.setSelect_count(0);
        ballView_first.setSelect_count(0);
        ballView_two.setSelect_count(0);
        ballView_three.setSelect_count(0);

        ballView_dan.invalidate();
        ballView_first.invalidate();
        ballView_two.invalidate();
        ballView_three.invalidate();
    }

    @Override
    public int getLotteryId() {
        return LotteryIDUtils.SD11XUAN5_LOTTERY_ID_INT;
    }

    @Override
    protected void popupClickItem(int arg2) {
        popupId = arg2;
        top_popup.setCheckItem(popupId);
        topView.setCenterText(AppLotteryInfos.getLotteryName(getLotteryId()) + " - "
                + popup_items.get(popupId).str1);

    }

    protected void setRenXuan(int tiShiId) {
        prize_tishi_tv.setText(tiShiId);
        isYao = true;

        ball_ll_dan.setVisibility(View.GONE);
        ball_ll_two.setVisibility(View.GONE);
        ball_ll_three.setVisibility(View.GONE);

        balltitle_first.setText(getString(R.string.gp_11xuan5_balltitle_xuanhao));
        ball_tiShi_first.setText("");
        ballView_first.setSelect_max(ball_count);
    }

    protected void setDanTuo(int tiShiId_dan, int max_dan) {
        isYao = false;

        ball_ll_dan.setVisibility(View.VISIBLE);
        ball_ll_two.setVisibility(View.GONE);
        ball_ll_three.setVisibility(View.GONE);

        ballView_dan.setSelect_max(max_dan);// 胆码最多可选球数
        ball_tiShi_dan.setText(getString(tiShiId_dan));

        ballView_first.setSelect_max(ball_count - 1);// 拖码最多可选球数
        balltitle_first.setText(getString(R.string.tuonum));
        ball_tiShi_first.setText(getString(R.string.gp_11xuan5_tishi_ren_tuo));
    }

    @Override
    protected void addHistoryView(ArrayList<PrizeHistoryItem> historyItems, boolean isWaitting) {
        ll_history.removeAllViews();
        ll_history.addView(new NumHistoryPrizeView(getContext(), historyItems).getView());
    }

    @Override
    public void randomBallNum() {
        // TODO Auto-generated method stub
        clear();
        switch (wanFaId) {
            case LotteryIDUtils.SD11XUAN5_LOTTERY_RENER_DAN_ID_INT:
            case LotteryIDUtils.SD11XUAN5_LOTTERY_RENER_FU_ID_INT:
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENER_DAN_ID_INT;
                randomRen(2);
                break;
            case LotteryIDUtils.SD11XUAN5_LOTTERY_RENSAN_DAN_ID_INT:
            case LotteryIDUtils.SD11XUAN5_LOTTERY_RENSAN_FU_ID_INT:
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENSAN_DAN_ID_INT;
                randomRen(3);
                break;
            case LotteryIDUtils.SD11XUAN5_LOTTERY_RENSI_DAN_ID_INT:
            case LotteryIDUtils.SD11XUAN5_LOTTERY_RENSI_FU_ID_INT:
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENSI_DAN_ID_INT;
                randomRen(4);
                break;
            case LotteryIDUtils.SD11XUAN5_LOTTERY_RENWU_DAN_ID_INT:
            case LotteryIDUtils.SD11XUAN5_LOTTERY_RENWU_FU_ID_INT:
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENWU_DAN_ID_INT;
                randomRen(5);
                break;
            case LotteryIDUtils.SD11XUAN5_LOTTERY_RENLIU_DAN_ID_INT:
            case LotteryIDUtils.SD11XUAN5_LOTTERY_RENLIU_FU_ID_INT:
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENLIU_DAN_ID_INT;
                randomRen(6);
                break;
            case LotteryIDUtils.SD11XUAN5_LOTTERY_RENQI_DAN_ID_INT:
            case LotteryIDUtils.SD11XUAN5_LOTTERY_RENQI_FU_ID_INT:
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENQI_DAN_ID_INT;
                randomRen(7);
                break;
            case LotteryIDUtils.SD11XUAN5_LOTTERY_RENBA_DAN_ID_INT:
            case LotteryIDUtils.SD11XUAN5_LOTTERY_RENBA_FU_ID_INT:
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_RENBA_DAN_ID_INT;
                randomRen(8);
                break;
            case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANYI_DAN_ID_INT:
            case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANYI_FU_ID_INT:
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_QIANYI_DAN_ID_INT;
                randomRen(1);
                break;
            case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANER_ZU_DAN_ID_INT:
            case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANER_ZU_FU_ID_INT:
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_QIANER_ZU_DAN_ID_INT;
                randomRen(2);
                break;
            case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANSAN_ZU_DAN_ID_INT:
            case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANSAN_ZU_FU_ID_INT:
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_QIANSAN_ZU_DAN_ID_INT;
                randomRen(3);
                break;
            case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANER_DAN_ID_INT:
            case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANER_FU_ID_INT:
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_QIANER_DAN_ID_INT;
                randomZhi(2);
                break;
            case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANSAN_DAN_ID_INT:
            case LotteryIDUtils.SD11XUAN5_LOTTERY_QIANSAN_FU_ID_INT:
                wanFaId = LotteryIDUtils.SD11XUAN5_LOTTERY_QIANSAN_DAN_ID_INT;
                randomZhi(3);
                break;
            default:
                break;
        }

        ballView_dan.invalidate();
        ballView_first.invalidate();
        ballView_two.invalidate();
        ballView_three.invalidate();

        ballClick();

    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()){
            case R.id.shake_random_ll:
                randomBallNum();
                break;
        }
    }

    /**
     * 机选号（一排球）
     *
     * @param num
     */
    protected void randomRen(int num) {
        int arr[] = RandomFactory.getRandom(
                LotteryIDUtils.SD11XUAN5_LOTTERY_ID_INT).randomDanHang(num);
        for (int i = 0; i < arr.length; i++) {
            balls_firstLine.get(arr[i]).setSelected(true);
        }
    }

    /**
     * 机选号（多排球）
     *
     * @param num
     */
    protected void randomZhi(int num) {
        int arr[] = RandomFactory.getRandom(
                LotteryIDUtils.SD11XUAN5_LOTTERY_ID_INT).randomDanHang(3);
        int first = arr[0];
        int two = arr[1];
        int thire = arr[2];
        balls_firstLine.get(first).setSelected(true);
        balls_twoLine.get(two).setSelected(true);
        if (num == 3) {
            balls_threeLine.get(thire).setSelected(true);
        }
    }

    @Override
    public String getHelpUrl() {
        // TODO Auto-generated method stub
        return HelpUrlConstants.Help_SD115;
    }

    @Override
    public String getHelpTitle() {
        // TODO Auto-generated method stub
        return getString(R.string.help_11xuan5);
    }

    @Override
    public void ballClick(WeiZhi info) {
        // TODO Auto-generated method stub
        WeiZhi w = info;
        // TODO Auto-generated method stub
        int left = w.getLeft() - 5;
        int right = w.getRight() + 5;
        int top = (int) ((ball_linear.getY1() - w.getPointY() + w.getTop())
                - (w.getBottom() - w.getTop()) - 10);
        int bottom = (int) (ball_linear.getY1() - w.getPointY() + w.getTop());
        Rect rect = new Rect(left, top, right, bottom);
        moveQiu.setRect(rect, w.getNum(), w.getType(), w.isShowMoveBall);
    }

    @Override
    public void ballClick() {
        // TODO Auto-generated method stub

        long zhushu = getZhushu();
        long money = zhushu * 2;

        bottomView.setMoRenText1(zhushu + "注 ");
        bottomView.setMoRenText2("共" + money + "米");

    }

    protected long getZhushu() {
        return ZhuShuFactory.getZhuShu(wanFaId).betZhuShu(arr_infos);
    }

    @Override
    protected void net() {
        topView.startRightAnim();
        super.net();
    }

    @Override
    public Intent getTrendIntent() {
        Intent intent = new Intent(getContext(), Gp11x5TrendActivity.class);
        intent.putExtra(IntentParamUtils.LOTTERYID, getLotteryId());
        return intent;
    }

    @Override
    protected void addMissValue() {
        super.addMissValue();
        missKey = AppLotteryInfos.getMissKey2(getLotteryId(), popupId);
        if (popup_itemsId[popupId] == R.string.gp_11xuan5_popu_qian1) {
            setMissKey(missKey, new String[]{"ge"});
        }else if (popup_itemsId[popupId] == R.string.gp_11xuan5_popu_qian2_zhi) {
            setMissKey(missKey, new String[]{"shi","ge"});
        } else if (popup_itemsId[popupId] == R.string.gp_11xuan5_popu_qian3_zhi) {
            setMissKey(missKey, new String[]{"bai","shi","ge"});
        } else {
            setMissKey(missKey, new String[]{"miss"});
        }
    }
}
